Skip to content

Conversation

@schiller-manuel
Copy link
Contributor

@schiller-manuel schiller-manuel commented Dec 25, 2025

Summary by CodeRabbit

  • New Features

    • Added a new middleware demo route that showcases server↔client function metadata propagation and interactive UI to exercise it.
  • Tests

    • Added end-to-end tests validating middleware metadata flow between SSR loader and client-invoked calls.
  • Documentation

    • Exported typed metadata interfaces for client and server middleware usage.
  • Chores

    • Updated runtime plumbing and serialization to surface metadata objects through RPC and SSR helpers.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 25, 2025

📝 Walkthrough

Walkthrough

Replaces scattered functionId/filename usage with structured serverFnMeta (id, name, filename) across client/server RPCs, middleware interfaces, compiler plugin, serializers, tests, and adds an e2e route + tests demonstrating middleware metadata flow.

Changes

Cohort / File(s) Summary
Type defs & exports
packages/start-client-core/src/constants.ts, packages/start-client-core/src/index.tsx
Add ClientFnMeta and ServerFnMeta types and export them.
Middleware interfaces
packages/start-client-core/src/createMiddleware.ts
Replace functionId/filename fields with serverFnMeta: ServerFnMeta (server) / ClientFnMeta (client) in middleware option shapes.
Client RPC surface
packages/start-client-core/src/client-rpc/createClientRpc.ts, packages/start-client-core/src/client/ServerFunctionSerializationAdapter.ts
createClientRpc now exposes serverFnMeta; serialization adapter recognizes { serverFnMeta: { id } } and maps to { functionId }.
Server function wiring
packages/start-client-core/src/createServerFn.ts
CompiledFetcherFn includes serverFnMeta; server context is populated with serverFnMeta; middleware option types updated.
Server RPC / SSR RPC
packages/start-server-core/src/createServerRpc.ts, packages/start-server-core/src/createSsrRpc.ts
createServerRpc now accepts ServerFnMeta object; SSR RPC returns serverFnMeta instead of functionId.
Server serialization adapter
packages/start-server-core/src/serializer/ServerFunctionSerializationAdapter.ts
Type guard and toSerializable updated to use serverFnMeta; fromSerializable behavior adjusted.
Compiler plugin
packages/start-plugin-core/src/start-compiler-plugin/handleCreateServerFn.ts
RPC templates updated to emit structured serverFnMeta objects (id, name, filename); generator signatures adjusted.
Tests & snapshots (compiler/plugin)
packages/start-plugin-core/tests/createServerFn/*, packages/start-plugin-core/tests/createServerFn/snapshots/**/*
Updated test fixtures/snapshots to reflect object-form metadata and absolute paths; many encoded RPC payloads and import paths changed.
Static server-fn middleware
packages/start-static-server-functions/src/staticFunctionMiddleware.ts
Cache lookup/storage now uses ctx.serverFnMeta.id instead of ctx.functionId.
E2E route & route tree
e2e/react-start/server-functions/src/routes/middleware/function-metadata.tsx, .../routeTree.gen.ts
Add new route demonstrating middleware metadata propagation and register it in the generated route tree.
Middleware example link
e2e/react-start/server-functions/src/routes/middleware/index.tsx
Add navigation link to the new function-metadata example.
E2E tests
e2e/react-start/server-functions/tests/server-functions.spec.ts
Add end-to-end test(s) validating client receives partial meta (id) while server middleware receives full meta (id, name, filename).

Sequence Diagram(s)

sequenceDiagram
  participant Browser
  participant ClientMiddleware
  participant ClientRPC
  participant Server
  participant ServerMiddleware

  Browser->>ClientMiddleware: init call (client-side middleware sees serverFnMeta.id)
  Browser->>ClientRPC: invoke server function (encodes serverFnMeta in request)
  ClientRPC->>Server: HTTP request with serverFnMeta payload
  Server->>ServerMiddleware: incoming request (ServerMiddleware receives full serverFnMeta)
  ServerMiddleware->>Server: attach serverFnMeta to execution ctx
  Server->>Server: execute server function -> returns { serverMeta, clientCapturedMeta }
  Server->>ClientRPC: response
  ClientRPC->>ClientMiddleware: deliver any returned clientCapturedMeta via sendContext
  ClientMiddleware->>Browser: client updates UI with returned metadata
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

Suggested reviewers

  • chorobin
  • nlynzaad

Poem

🐰 Hops the rabbit with a tiny quill,

IDs tucked in objects, neat and still,
From client to server the metadata flows,
Middleware whispers what everyone knows,
A tidy harvest of metadata thrills 🌿

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 35.71% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title 'feat: add server fn meta' accurately describes the primary change: introducing server function metadata (serverFnMeta) throughout the codebase to replace individual functionId and filename parameters.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

Comment @coderabbitai help to get the list of available commands and usage tips.

@nx-cloud
Copy link

nx-cloud bot commented Dec 25, 2025

View your CI Pipeline Execution ↗ for commit 1510871

Command Status Duration Result
nx affected --targets=test:eslint,test:unit,tes... ✅ Succeeded 16m 15s View ↗
nx run-many --target=build --exclude=examples/*... ✅ Succeeded 34s View ↗

☁️ Nx Cloud last updated this comment at 2026-01-11 08:54:07 UTC

@pkg-pr-new
Copy link

pkg-pr-new bot commented Dec 25, 2025

More templates

@tanstack/arktype-adapter

npm i https://pkg.pr.new/TanStack/router/@tanstack/arktype-adapter@6213

@tanstack/eslint-plugin-router

npm i https://pkg.pr.new/TanStack/router/@tanstack/eslint-plugin-router@6213

@tanstack/history

npm i https://pkg.pr.new/TanStack/router/@tanstack/history@6213

@tanstack/nitro-v2-vite-plugin

npm i https://pkg.pr.new/TanStack/router/@tanstack/nitro-v2-vite-plugin@6213

@tanstack/react-router

npm i https://pkg.pr.new/TanStack/router/@tanstack/react-router@6213

@tanstack/react-router-devtools

npm i https://pkg.pr.new/TanStack/router/@tanstack/react-router-devtools@6213

@tanstack/react-router-ssr-query

npm i https://pkg.pr.new/TanStack/router/@tanstack/react-router-ssr-query@6213

@tanstack/react-start

npm i https://pkg.pr.new/TanStack/router/@tanstack/react-start@6213

@tanstack/react-start-client

npm i https://pkg.pr.new/TanStack/router/@tanstack/react-start-client@6213

@tanstack/react-start-server

npm i https://pkg.pr.new/TanStack/router/@tanstack/react-start-server@6213

@tanstack/router-cli

npm i https://pkg.pr.new/TanStack/router/@tanstack/router-cli@6213

@tanstack/router-core

npm i https://pkg.pr.new/TanStack/router/@tanstack/router-core@6213

@tanstack/router-devtools

npm i https://pkg.pr.new/TanStack/router/@tanstack/router-devtools@6213

@tanstack/router-devtools-core

npm i https://pkg.pr.new/TanStack/router/@tanstack/router-devtools-core@6213

@tanstack/router-generator

npm i https://pkg.pr.new/TanStack/router/@tanstack/router-generator@6213

@tanstack/router-plugin

npm i https://pkg.pr.new/TanStack/router/@tanstack/router-plugin@6213

@tanstack/router-ssr-query-core

npm i https://pkg.pr.new/TanStack/router/@tanstack/router-ssr-query-core@6213

@tanstack/router-utils

npm i https://pkg.pr.new/TanStack/router/@tanstack/router-utils@6213

@tanstack/router-vite-plugin

npm i https://pkg.pr.new/TanStack/router/@tanstack/router-vite-plugin@6213

@tanstack/solid-router

npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-router@6213

@tanstack/solid-router-devtools

npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-router-devtools@6213

@tanstack/solid-router-ssr-query

npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-router-ssr-query@6213

@tanstack/solid-start

npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-start@6213

@tanstack/solid-start-client

npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-start-client@6213

@tanstack/solid-start-server

npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-start-server@6213

@tanstack/start-client-core

npm i https://pkg.pr.new/TanStack/router/@tanstack/start-client-core@6213

@tanstack/start-fn-stubs

npm i https://pkg.pr.new/TanStack/router/@tanstack/start-fn-stubs@6213

@tanstack/start-plugin-core

npm i https://pkg.pr.new/TanStack/router/@tanstack/start-plugin-core@6213

@tanstack/start-server-core

npm i https://pkg.pr.new/TanStack/router/@tanstack/start-server-core@6213

@tanstack/start-static-server-functions

npm i https://pkg.pr.new/TanStack/router/@tanstack/start-static-server-functions@6213

@tanstack/start-storage-context

npm i https://pkg.pr.new/TanStack/router/@tanstack/start-storage-context@6213

@tanstack/valibot-adapter

npm i https://pkg.pr.new/TanStack/router/@tanstack/valibot-adapter@6213

@tanstack/virtual-file-routes

npm i https://pkg.pr.new/TanStack/router/@tanstack/virtual-file-routes@6213

@tanstack/vue-router

npm i https://pkg.pr.new/TanStack/router/@tanstack/vue-router@6213

@tanstack/vue-router-devtools

npm i https://pkg.pr.new/TanStack/router/@tanstack/vue-router-devtools@6213

@tanstack/vue-router-ssr-query

npm i https://pkg.pr.new/TanStack/router/@tanstack/vue-router-ssr-query@6213

@tanstack/vue-start

npm i https://pkg.pr.new/TanStack/router/@tanstack/vue-start@6213

@tanstack/vue-start-client

npm i https://pkg.pr.new/TanStack/router/@tanstack/vue-start-client@6213

@tanstack/vue-start-server

npm i https://pkg.pr.new/TanStack/router/@tanstack/vue-start-server@6213

@tanstack/zod-adapter

npm i https://pkg.pr.new/TanStack/router/@tanstack/zod-adapter@6213

commit: 1510871

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
packages/start-server-core/src/serializer/ServerFunctionSerializationAdapter.ts (1)

16-26: Remove the as never type assertion and provide explicit typing for the returned function.

The as never cast violates TanStack Router's type safety practices and masks real type mismatches at call sites. According to TanStack Router patterns, the proper approach is to either ensure the return type is correctly inferred or provide an explicit, specific type assertion rather than never.

Consider either:

  1. Properly type the fn function with a specific interface/type that matches what callers expect (e.g., ServerFunction<any, any>)
  2. Use a more specific type assertion that reflects the actual callable signature instead of never

Also verify: Was the createServerRpc(functionId, fn) wrapper intentionally removed from this location? If it previously added properties like url, serverFnMeta, or a TSS_SERVER_FUNCTION symbol that downstream consumers depend on, its removal may break those expectations.

📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2f46e9b and add0805.

📒 Files selected for processing (34)
  • e2e/react-start/server-functions/src/routeTree.gen.ts
  • e2e/react-start/server-functions/src/routes/middleware/function-metadata.tsx
  • e2e/react-start/server-functions/src/routes/middleware/index.tsx
  • e2e/react-start/server-functions/tests/server-functions.spec.ts
  • packages/start-client-core/src/client-rpc/createClientRpc.ts
  • packages/start-client-core/src/client/ServerFunctionSerializationAdapter.ts
  • packages/start-client-core/src/constants.ts
  • packages/start-client-core/src/createMiddleware.ts
  • packages/start-client-core/src/createServerFn.ts
  • packages/start-client-core/src/index.tsx
  • packages/start-plugin-core/src/start-compiler-plugin/handleCreateServerFn.ts
  • packages/start-plugin-core/tests/createServerFn/createServerFn.test.ts
  • packages/start-plugin-core/tests/createServerFn/snapshots/client/createServerFnDestructured.tsx
  • packages/start-plugin-core/tests/createServerFn/snapshots/client/createServerFnDestructuredRename.tsx
  • packages/start-plugin-core/tests/createServerFn/snapshots/client/createServerFnStarImport.tsx
  • packages/start-plugin-core/tests/createServerFn/snapshots/client/createServerFnValidator.tsx
  • packages/start-plugin-core/tests/createServerFn/snapshots/client/factory.tsx
  • packages/start-plugin-core/tests/createServerFn/snapshots/client/isomorphic-fns.tsx
  • packages/start-plugin-core/tests/createServerFn/snapshots/server-caller/createServerFnDestructured.tsx
  • packages/start-plugin-core/tests/createServerFn/snapshots/server-caller/createServerFnDestructuredRename.tsx
  • packages/start-plugin-core/tests/createServerFn/snapshots/server-caller/createServerFnStarImport.tsx
  • packages/start-plugin-core/tests/createServerFn/snapshots/server-caller/createServerFnValidator.tsx
  • packages/start-plugin-core/tests/createServerFn/snapshots/server-caller/factory.tsx
  • packages/start-plugin-core/tests/createServerFn/snapshots/server-caller/isomorphic-fns.tsx
  • packages/start-plugin-core/tests/createServerFn/snapshots/server-provider/createServerFnDestructured.tsx
  • packages/start-plugin-core/tests/createServerFn/snapshots/server-provider/createServerFnDestructuredRename.tsx
  • packages/start-plugin-core/tests/createServerFn/snapshots/server-provider/createServerFnStarImport.tsx
  • packages/start-plugin-core/tests/createServerFn/snapshots/server-provider/createServerFnValidator.tsx
  • packages/start-plugin-core/tests/createServerFn/snapshots/server-provider/factory.tsx
  • packages/start-plugin-core/tests/createServerFn/snapshots/server-provider/isomorphic-fns.tsx
  • packages/start-server-core/src/createServerRpc.ts
  • packages/start-server-core/src/createSsrRpc.ts
  • packages/start-server-core/src/serializer/ServerFunctionSerializationAdapter.ts
  • packages/start-static-server-functions/src/staticFunctionMiddleware.ts
🧰 Additional context used
📓 Path-based instructions (2)
**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

Use TypeScript strict mode with extensive type safety for all code

Files:

  • packages/start-client-core/src/constants.ts
  • packages/start-plugin-core/tests/createServerFn/snapshots/client/createServerFnValidator.tsx
  • e2e/react-start/server-functions/src/routes/middleware/index.tsx
  • packages/start-static-server-functions/src/staticFunctionMiddleware.ts
  • packages/start-plugin-core/tests/createServerFn/snapshots/client/createServerFnDestructured.tsx
  • e2e/react-start/server-functions/src/routeTree.gen.ts
  • e2e/react-start/server-functions/tests/server-functions.spec.ts
  • packages/start-plugin-core/tests/createServerFn/snapshots/client/createServerFnStarImport.tsx
  • packages/start-server-core/src/createServerRpc.ts
  • packages/start-server-core/src/createSsrRpc.ts
  • packages/start-client-core/src/index.tsx
  • packages/start-plugin-core/tests/createServerFn/snapshots/server-provider/factory.tsx
  • packages/start-client-core/src/client-rpc/createClientRpc.ts
  • packages/start-plugin-core/tests/createServerFn/snapshots/server-caller/createServerFnDestructured.tsx
  • packages/start-plugin-core/tests/createServerFn/snapshots/server-caller/isomorphic-fns.tsx
  • packages/start-client-core/src/createMiddleware.ts
  • packages/start-plugin-core/tests/createServerFn/snapshots/server-provider/createServerFnValidator.tsx
  • e2e/react-start/server-functions/src/routes/middleware/function-metadata.tsx
  • packages/start-plugin-core/tests/createServerFn/snapshots/server-caller/createServerFnStarImport.tsx
  • packages/start-plugin-core/tests/createServerFn/snapshots/server-provider/isomorphic-fns.tsx
  • packages/start-plugin-core/tests/createServerFn/snapshots/server-caller/createServerFnDestructuredRename.tsx
  • packages/start-client-core/src/createServerFn.ts
  • packages/start-server-core/src/serializer/ServerFunctionSerializationAdapter.ts
  • packages/start-plugin-core/tests/createServerFn/snapshots/server-caller/createServerFnValidator.tsx
  • packages/start-plugin-core/tests/createServerFn/snapshots/client/isomorphic-fns.tsx
  • packages/start-plugin-core/tests/createServerFn/snapshots/client/factory.tsx
  • packages/start-client-core/src/client/ServerFunctionSerializationAdapter.ts
  • packages/start-plugin-core/tests/createServerFn/snapshots/client/createServerFnDestructuredRename.tsx
  • packages/start-plugin-core/tests/createServerFn/snapshots/server-provider/createServerFnDestructuredRename.tsx
  • packages/start-plugin-core/tests/createServerFn/snapshots/server-caller/factory.tsx
  • packages/start-plugin-core/src/start-compiler-plugin/handleCreateServerFn.ts
  • packages/start-plugin-core/tests/createServerFn/createServerFn.test.ts
  • packages/start-plugin-core/tests/createServerFn/snapshots/server-provider/createServerFnStarImport.tsx
  • packages/start-plugin-core/tests/createServerFn/snapshots/server-provider/createServerFnDestructured.tsx
**/*.{js,ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

Implement ESLint rules for router best practices using the ESLint plugin router

Files:

  • packages/start-client-core/src/constants.ts
  • packages/start-plugin-core/tests/createServerFn/snapshots/client/createServerFnValidator.tsx
  • e2e/react-start/server-functions/src/routes/middleware/index.tsx
  • packages/start-static-server-functions/src/staticFunctionMiddleware.ts
  • packages/start-plugin-core/tests/createServerFn/snapshots/client/createServerFnDestructured.tsx
  • e2e/react-start/server-functions/src/routeTree.gen.ts
  • e2e/react-start/server-functions/tests/server-functions.spec.ts
  • packages/start-plugin-core/tests/createServerFn/snapshots/client/createServerFnStarImport.tsx
  • packages/start-server-core/src/createServerRpc.ts
  • packages/start-server-core/src/createSsrRpc.ts
  • packages/start-client-core/src/index.tsx
  • packages/start-plugin-core/tests/createServerFn/snapshots/server-provider/factory.tsx
  • packages/start-client-core/src/client-rpc/createClientRpc.ts
  • packages/start-plugin-core/tests/createServerFn/snapshots/server-caller/createServerFnDestructured.tsx
  • packages/start-plugin-core/tests/createServerFn/snapshots/server-caller/isomorphic-fns.tsx
  • packages/start-client-core/src/createMiddleware.ts
  • packages/start-plugin-core/tests/createServerFn/snapshots/server-provider/createServerFnValidator.tsx
  • e2e/react-start/server-functions/src/routes/middleware/function-metadata.tsx
  • packages/start-plugin-core/tests/createServerFn/snapshots/server-caller/createServerFnStarImport.tsx
  • packages/start-plugin-core/tests/createServerFn/snapshots/server-provider/isomorphic-fns.tsx
  • packages/start-plugin-core/tests/createServerFn/snapshots/server-caller/createServerFnDestructuredRename.tsx
  • packages/start-client-core/src/createServerFn.ts
  • packages/start-server-core/src/serializer/ServerFunctionSerializationAdapter.ts
  • packages/start-plugin-core/tests/createServerFn/snapshots/server-caller/createServerFnValidator.tsx
  • packages/start-plugin-core/tests/createServerFn/snapshots/client/isomorphic-fns.tsx
  • packages/start-plugin-core/tests/createServerFn/snapshots/client/factory.tsx
  • packages/start-client-core/src/client/ServerFunctionSerializationAdapter.ts
  • packages/start-plugin-core/tests/createServerFn/snapshots/client/createServerFnDestructuredRename.tsx
  • packages/start-plugin-core/tests/createServerFn/snapshots/server-provider/createServerFnDestructuredRename.tsx
  • packages/start-plugin-core/tests/createServerFn/snapshots/server-caller/factory.tsx
  • packages/start-plugin-core/src/start-compiler-plugin/handleCreateServerFn.ts
  • packages/start-plugin-core/tests/createServerFn/createServerFn.test.ts
  • packages/start-plugin-core/tests/createServerFn/snapshots/server-provider/createServerFnStarImport.tsx
  • packages/start-plugin-core/tests/createServerFn/snapshots/server-provider/createServerFnDestructured.tsx
🧠 Learnings (6)
📚 Learning: 2025-12-16T02:59:11.506Z
Learnt from: schiller-manuel
Repo: TanStack/router PR: 6104
File: packages/start-plugin-core/tests/split-exports-plugin/snapshots/exports/functionExports.ts:1-1
Timestamp: 2025-12-16T02:59:11.506Z
Learning: In transformation test snapshots (e.g., split-exports plugin), comments at the top of snapshot files often describe the original input scenario being tested (e.g., "Multiple function exports") rather than the transformed output in the snapshot itself. This helps document what transformation is being validated.

Applied to files:

  • packages/start-plugin-core/tests/createServerFn/snapshots/client/createServerFnDestructured.tsx
  • packages/start-plugin-core/tests/createServerFn/snapshots/client/createServerFnStarImport.tsx
  • packages/start-plugin-core/tests/createServerFn/snapshots/server-provider/factory.tsx
  • packages/start-plugin-core/tests/createServerFn/snapshots/server-caller/createServerFnDestructured.tsx
  • packages/start-plugin-core/tests/createServerFn/snapshots/server-caller/createServerFnStarImport.tsx
  • packages/start-plugin-core/tests/createServerFn/snapshots/server-provider/isomorphic-fns.tsx
  • packages/start-plugin-core/tests/createServerFn/snapshots/server-caller/createServerFnDestructuredRename.tsx
  • packages/start-plugin-core/tests/createServerFn/snapshots/client/createServerFnDestructuredRename.tsx
  • packages/start-plugin-core/tests/createServerFn/snapshots/server-provider/createServerFnDestructuredRename.tsx
  • packages/start-plugin-core/tests/createServerFn/snapshots/server-caller/factory.tsx
  • packages/start-plugin-core/tests/createServerFn/createServerFn.test.ts
  • packages/start-plugin-core/tests/createServerFn/snapshots/server-provider/createServerFnStarImport.tsx
  • packages/start-plugin-core/tests/createServerFn/snapshots/server-provider/createServerFnDestructured.tsx
📚 Learning: 2025-10-01T18:31:35.420Z
Learnt from: schiller-manuel
Repo: TanStack/router PR: 5330
File: e2e/react-start/custom-basepath/src/routeTree.gen.ts:58-61
Timestamp: 2025-10-01T18:31:35.420Z
Learning: Do not review files named `routeTree.gen.ts` in TanStack Router repositories, as these are autogenerated files that should not be manually modified.

Applied to files:

  • e2e/react-start/server-functions/src/routeTree.gen.ts
📚 Learning: 2025-12-17T02:17:55.086Z
Learnt from: schiller-manuel
Repo: TanStack/router PR: 6120
File: packages/router-generator/src/generator.ts:654-657
Timestamp: 2025-12-17T02:17:55.086Z
Learning: In `packages/router-generator/src/generator.ts`, pathless_layout routes must receive a `path` property when they have a `cleanedPath`, even though they are non-path routes. This is necessary because child routes inherit the path from their parent, and without this property, child routes would not have the correct full path at runtime.

Applied to files:

  • e2e/react-start/server-functions/src/routeTree.gen.ts
📚 Learning: 2025-10-08T08:11:47.088Z
Learnt from: nlynzaad
Repo: TanStack/router PR: 5402
File: packages/router-generator/tests/generator/no-formatted-route-tree/routeTree.nonnested.snapshot.ts:19-21
Timestamp: 2025-10-08T08:11:47.088Z
Learning: Test snapshot files in the router-generator tests directory (e.g., files matching the pattern `packages/router-generator/tests/generator/**/routeTree*.snapshot.ts` or `routeTree*.snapshot.js`) should not be modified or have issues flagged, as they are fixtures used to verify the generator's output and are intentionally preserved as-is.

Applied to files:

  • e2e/react-start/server-functions/src/routeTree.gen.ts
  • packages/start-plugin-core/tests/createServerFn/snapshots/server-provider/factory.tsx
  • packages/start-plugin-core/tests/createServerFn/snapshots/server-caller/createServerFnDestructured.tsx
  • packages/start-plugin-core/tests/createServerFn/snapshots/server-caller/isomorphic-fns.tsx
  • packages/start-plugin-core/tests/createServerFn/snapshots/server-caller/createServerFnStarImport.tsx
  • packages/start-plugin-core/tests/createServerFn/snapshots/server-caller/createServerFnDestructuredRename.tsx
  • packages/start-plugin-core/tests/createServerFn/snapshots/client/createServerFnDestructuredRename.tsx
  • packages/start-plugin-core/tests/createServerFn/snapshots/server-caller/factory.tsx
  • packages/start-plugin-core/tests/createServerFn/createServerFn.test.ts
📚 Learning: 2025-09-28T21:41:45.233Z
Learnt from: nlynzaad
Repo: TanStack/router PR: 5284
File: e2e/react-start/basic/server.js:50-0
Timestamp: 2025-09-28T21:41:45.233Z
Learning: In Express v5, catch-all routes must use named wildcards. Use `/*splat` to match everything except root path, or `/{*splat}` (with braces) to match including root path. The old `*` syntax is not allowed and will cause "Missing parameter name" errors. This breaking change requires explicit naming of wildcard parameters.

Applied to files:

  • e2e/react-start/server-functions/src/routeTree.gen.ts
📚 Learning: 2025-11-02T16:16:24.898Z
Learnt from: nlynzaad
Repo: TanStack/router PR: 5732
File: packages/start-client-core/src/client/hydrateStart.ts:6-9
Timestamp: 2025-11-02T16:16:24.898Z
Learning: In packages/start-client-core/src/client/hydrateStart.ts, the `import/no-duplicates` ESLint disable is necessary for imports from `#tanstack-router-entry` and `#tanstack-start-entry` because both aliases resolve to the same placeholder file (`fake-start-entry.js`) in package.json during static analysis, even though they resolve to different files at runtime.

Applied to files:

  • packages/start-plugin-core/tests/createServerFn/snapshots/client/createServerFnStarImport.tsx
  • packages/start-client-core/src/index.tsx
  • packages/start-plugin-core/tests/createServerFn/snapshots/server-caller/createServerFnDestructured.tsx
  • packages/start-plugin-core/tests/createServerFn/snapshots/server-caller/isomorphic-fns.tsx
  • packages/start-plugin-core/tests/createServerFn/snapshots/server-caller/createServerFnStarImport.tsx
  • packages/start-plugin-core/tests/createServerFn/snapshots/server-provider/isomorphic-fns.tsx
  • packages/start-plugin-core/tests/createServerFn/snapshots/client/isomorphic-fns.tsx
  • packages/start-plugin-core/tests/createServerFn/snapshots/server-caller/factory.tsx
  • packages/start-plugin-core/tests/createServerFn/createServerFn.test.ts
🧬 Code graph analysis (23)
e2e/react-start/server-functions/src/routes/middleware/index.tsx (2)
e2e/react-start/server-functions/src/routes/middleware/function-metadata.tsx (1)
  • Route (35-38)
e2e/react-start/server-functions/src/routes/middleware/middleware-factory.tsx (1)
  • Route (72-74)
packages/start-plugin-core/tests/createServerFn/snapshots/client/createServerFnDestructured.tsx (1)
packages/start-client-core/src/client-rpc/createClientRpc.ts (1)
  • createClientRpc (5-18)
packages/start-server-core/src/createServerRpc.ts (2)
packages/start-client-core/src/constants.ts (1)
  • ServerFnMeta (23-28)
packages/start-client-core/src/index.tsx (1)
  • ServerFnMeta (87-87)
packages/start-server-core/src/createSsrRpc.ts (5)
packages/start-client-core/src/createServerFn.ts (1)
  • ServerFn (316-324)
packages/start-client-core/src/index.tsx (2)
  • ServerFn (62-62)
  • ClientFnMeta (87-87)
packages/start-plugin-core/src/start-compiler-plugin/types.ts (1)
  • ServerFn (79-93)
packages/start-server-core/src/tanstack-start.d.ts (1)
  • ServerFn (14-14)
packages/start-client-core/src/constants.ts (1)
  • ClientFnMeta (14-17)
packages/start-plugin-core/tests/createServerFn/snapshots/server-provider/factory.tsx (3)
packages/start-server-core/src/createServerRpc.ts (1)
  • createServerRpc (6-17)
packages/start-plugin-core/tests/createServerFn/snapshots/client/factory.tsx (3)
  • myAuthedFn (27-27)
  • createAuthServerFn (25-25)
  • deleteUserFn (28-28)
packages/start-plugin-core/tests/createServerFn/snapshots/server-caller/factory.tsx (3)
  • myAuthedFn (27-27)
  • createAuthServerFn (25-25)
  • deleteUserFn (28-28)
packages/start-client-core/src/client-rpc/createClientRpc.ts (3)
packages/start-client-core/src/constants.ts (1)
  • ClientFnMeta (14-17)
packages/start-client-core/src/index.tsx (1)
  • ClientFnMeta (87-87)
packages/start-client-core/src/client-rpc/serverFnFetcher.ts (1)
  • serverFnFetcher (20-106)
packages/start-plugin-core/tests/createServerFn/snapshots/server-caller/createServerFnDestructured.tsx (2)
packages/start-server-core/src/createSsrRpc.ts (1)
  • createSsrRpc (8-26)
packages/start-client-core/src/createServerFn.ts (1)
  • createServerFn (53-176)
packages/start-plugin-core/tests/createServerFn/snapshots/server-caller/isomorphic-fns.tsx (2)
packages/start-client-core/src/createServerFn.ts (1)
  • createServerFn (53-176)
packages/start-server-core/src/createSsrRpc.ts (1)
  • createSsrRpc (8-26)
packages/start-client-core/src/createMiddleware.ts (2)
packages/start-client-core/src/constants.ts (2)
  • ServerFnMeta (23-28)
  • ClientFnMeta (14-17)
packages/start-client-core/src/index.tsx (2)
  • ServerFnMeta (87-87)
  • ClientFnMeta (87-87)
packages/start-plugin-core/tests/createServerFn/snapshots/server-provider/createServerFnValidator.tsx (6)
packages/start-server-core/src/createServerRpc.ts (1)
  • createServerRpc (6-17)
packages/start-plugin-core/tests/createServerFn/snapshots/client/createServerFnDestructured.tsx (1)
  • withUseServer (3-5)
packages/start-plugin-core/tests/createServerFn/snapshots/client/createServerFnStarImport.tsx (1)
  • withUseServer (3-5)
packages/start-plugin-core/tests/createServerFn/snapshots/server-caller/createServerFnDestructured.tsx (1)
  • withUseServer (4-6)
packages/start-plugin-core/tests/createServerFn/snapshots/server-caller/createServerFnDestructuredRename.tsx (1)
  • withUseServer (3-5)
packages/start-plugin-core/tests/createServerFn/snapshots/server-caller/createServerFnStarImport.tsx (1)
  • withUseServer (3-5)
e2e/react-start/server-functions/src/routes/middleware/function-metadata.tsx (2)
packages/start-client-core/src/createMiddleware.ts (1)
  • createMiddleware (29-62)
packages/start-client-core/src/createServerFn.ts (1)
  • createServerFn (53-176)
packages/start-plugin-core/tests/createServerFn/snapshots/server-provider/isomorphic-fns.tsx (1)
packages/start-server-core/src/createServerRpc.ts (1)
  • createServerRpc (6-17)
packages/start-plugin-core/tests/createServerFn/snapshots/server-caller/createServerFnDestructuredRename.tsx (2)
packages/start-server-core/src/createSsrRpc.ts (1)
  • createSsrRpc (8-26)
packages/start-plugin-core/tests/createServerFn/snapshots/server-caller/createServerFnDestructured.tsx (3)
  • withoutUseServer (13-15)
  • withVariable (16-18)
  • withZodValidator (19-21)
packages/start-client-core/src/createServerFn.ts (1)
packages/start-client-core/src/constants.ts (2)
  • ServerFnMeta (23-28)
  • ClientFnMeta (14-17)
packages/start-server-core/src/serializer/ServerFunctionSerializationAdapter.ts (2)
packages/start-client-core/src/constants.ts (1)
  • TSS_SERVER_FUNCTION (2-2)
packages/start-client-core/src/index.tsx (1)
  • TSS_SERVER_FUNCTION (83-83)
packages/start-plugin-core/tests/createServerFn/snapshots/server-caller/createServerFnValidator.tsx (1)
packages/start-server-core/src/createSsrRpc.ts (1)
  • createSsrRpc (8-26)
packages/start-plugin-core/tests/createServerFn/snapshots/client/isomorphic-fns.tsx (2)
packages/start-client-core/src/createServerFn.ts (1)
  • createServerFn (53-176)
packages/start-client-core/src/client-rpc/createClientRpc.ts (1)
  • createClientRpc (5-18)
packages/start-plugin-core/tests/createServerFn/snapshots/client/factory.tsx (2)
packages/start-plugin-core/tests/createServerFn/snapshots/server-caller/factory.tsx (3)
  • myAuthedFn (27-27)
  • createAuthServerFn (25-25)
  • deleteUserFn (28-28)
packages/start-client-core/src/client-rpc/createClientRpc.ts (1)
  • createClientRpc (5-18)
packages/start-client-core/src/client/ServerFunctionSerializationAdapter.ts (2)
packages/start-client-core/src/constants.ts (1)
  • TSS_SERVER_FUNCTION (2-2)
packages/start-client-core/src/index.tsx (1)
  • TSS_SERVER_FUNCTION (83-83)
packages/start-plugin-core/tests/createServerFn/snapshots/client/createServerFnDestructuredRename.tsx (2)
packages/start-client-core/src/client-rpc/createClientRpc.ts (1)
  • createClientRpc (5-18)
packages/start-plugin-core/tests/createServerFn/snapshots/client/createServerFnDestructured.tsx (3)
  • withoutUseServer (12-14)
  • withVariable (15-17)
  • withZodValidator (18-20)
packages/start-plugin-core/tests/createServerFn/snapshots/server-provider/createServerFnDestructuredRename.tsx (2)
packages/start-server-core/src/createServerRpc.ts (1)
  • createServerRpc (6-17)
packages/start-plugin-core/tests/createServerFn/snapshots/server-caller/createServerFnDestructured.tsx (3)
  • withUseServer (4-6)
  • withoutUseServer (13-15)
  • withZodValidator (19-21)
packages/start-plugin-core/tests/createServerFn/snapshots/server-caller/factory.tsx (1)
packages/start-server-core/src/createSsrRpc.ts (1)
  • createSsrRpc (8-26)
packages/start-plugin-core/tests/createServerFn/snapshots/server-provider/createServerFnDestructured.tsx (1)
packages/start-server-core/src/createServerRpc.ts (1)
  • createServerRpc (6-17)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Test
  • GitHub Check: Preview
🔇 Additional comments (56)
packages/start-plugin-core/tests/createServerFn/snapshots/server-provider/isomorphic-fns.tsx (2)

6-10: LGTM! Structured metadata transformation is correct.

The transformation properly converts the server function handler to use the new structured serverFnMeta object format with id, name, and filename properties. This aligns with the PR objectives to replace scattered parameters with a unified metadata object.


13-17: Consistent transformation pattern.

This second handler transformation follows the same correct pattern as the first, demonstrating that the plugin properly handles multiple server functions within a single file with consistent metadata structure.

packages/start-static-server-functions/src/staticFunctionMiddleware.ts (1)

136-136: LGTM! Refactoring is complete and properly typed.

The refactoring from ctx.functionId to ctx.serverFnMeta.id is consistent across both client and server middleware paths. Type definitions confirm that ServerFnMeta and ClientFnMeta properly expose the id property in the middleware context, and no remaining ctx.functionId usage exists in the codebase. The ID value format is preserved since it's sourced from the same metadata object.

packages/start-plugin-core/tests/createServerFn/createServerFn.test.ts (5)

28-29: LGTM! Clear documentation of test setup.

Using an absolute path for test consistency is a good practice, and the comment clearly explains the reasoning.


125-149: Snapshots correctly updated to reflect the new API structure.

All inline snapshots have been consistently updated across client, server-caller, and server-provider scenarios:

  • Client: uses createClientRpc with encoded ID
  • Server-caller: uses createSsrRpc with encoded ID and dynamic import
  • Server-provider: uses createServerRpc with the new object structure

The changes are uniform and align well with the refactoring objectives.

Also applies to: 174-176, 188-190, 203-221


250-250: Consistent use of absolute paths in test setup.

The test cases correctly use the absolute path /test/src/test.ts, which is consistent with the changes in the compile helper function.

Also applies to: 301-301


316-320: Test expectations correctly updated for absolute paths.

The resolveId mock expectations are properly updated to use the absolute path /test/src/test.ts as the importer argument, which is consistent with the overall change to use absolute paths in tests.


142-146: No action required. The path handling is intentional and consistent.

The filename field uses a relative path (src/test.ts) by design, which is appropriate for middleware and runtime code that needs to reference the file. The test infrastructure path (/test/) and encoded ID prefix (/@id/) serve different purposes and do not represent inconsistencies. All snapshot files throughout the codebase confirm this is the expected behavior.

packages/start-client-core/src/constants.ts (1)

10-28: LGTM!

The new ClientFnMeta and ServerFnMeta interfaces are well-designed with clear separation of concerns—clients receive only the function ID while servers have access to full metadata (name, filename). The inheritance relationship is appropriate, and the JSDoc comments provide helpful context about compile-time embedding and security considerations.

packages/start-plugin-core/tests/createServerFn/snapshots/client/isomorphic-fns.tsx (1)

6-8: LGTM!

The snapshot correctly reflects the updated client-side compiled output. The createClientRpc calls receive the encoded function ID strings, which aligns with the client-only metadata approach (clients only get the ID, not full metadata).

packages/start-plugin-core/tests/createServerFn/snapshots/server-caller/isomorphic-fns.tsx (1)

6-8: LGTM!

The snapshot correctly reflects the SSR caller compiled output. The createSsrRpc calls receive the function ID string and an importer function, which aligns with the SSR RPC signature that uses ClientFnMeta internally (only containing the ID).

packages/start-client-core/src/index.tsx (1)

87-87: LGTM!

The type exports are correctly added to the public API surface. Using export type is appropriate for interfaces with no runtime component.

packages/start-server-core/src/serializer/ServerFunctionSerializationAdapter.ts (1)

8-15: LGTM!

The serialization adapter is correctly updated to work with the new serverFnMeta structure. The test type guard properly identifies server functions by their serverFnMeta.id property, and toSerializable correctly extracts the ID for serialization.

packages/start-client-core/src/createMiddleware.ts (3)

3-3: LGTM!

The import is correctly added for the new metadata types.


499-516: LGTM!

The FunctionMiddlewareServerFnOptions interface is correctly updated to use the structured serverFnMeta: ServerFnMeta type. Server middleware now has access to the full metadata (id, name, filename) through a single cohesive property.


601-612: LGTM!

The FunctionMiddlewareClientFnOptions interface correctly uses serverFnMeta: ClientFnMeta, which only exposes the function ID to client middleware. This aligns with the security consideration mentioned in the type definitions—client middleware should not have access to server internals like filename.

packages/start-plugin-core/src/start-compiler-plugin/handleCreateServerFn.ts (5)

15-33: LGTM!

The template updates correctly differentiate between provider files (which receive the full serverFnMeta object) and caller files (which only receive the functionId string). The comments clearly explain the purpose of each template.


120-134: LGTM!

The buildServerFnMetaObject helper is well-implemented. It creates a clean AST representation of the metadata object with id, name, and filename properties.


140-148: LGTM!

The generateProviderRpcStub function signature is correctly updated to accept the full serverFnMeta object expression for provider files.


150-185: LGTM!

The generateCallerRpcStub correctly continues to use only the functionId string for client and SSR callers. The added comment on line 153 clearly documents that callers only receive the function ID, not full metadata—maintaining the security boundary between client and server.


344-355: LGTM!

The provider file transformation correctly builds the serverFnMeta object with all three properties (id, name, filename) and passes it to the RPC stub generator. The variable naming is clear and the logic follows naturally from the helper function.

packages/start-plugin-core/tests/createServerFn/snapshots/server-provider/createServerFnValidator.tsx (1)

4-8: LGTM!

The snapshot correctly reflects the updated server-provider compiled output. The createServerRpc call now receives a structured metadata object with id, name, and filename properties, matching the ServerFnMeta interface. This provides server middleware with full context about the function being invoked.

packages/start-plugin-core/tests/createServerFn/snapshots/client/createServerFnValidator.tsx (1)

1-6: LGTM - Snapshot correctly reflects serverFnMeta refactor.

The updated base64-encoded payload passed to createClientRpc aligns with the PR's objective to use structured metadata objects instead of string IDs. This snapshot documents the expected plugin transformation output.

packages/start-plugin-core/tests/createServerFn/snapshots/client/createServerFnDestructuredRename.tsx (1)

1-14: LGTM - Consistent snapshot updates across all handlers.

All four server function handlers (withUseServer, withoutUseServer, withVariable, withZodValidator) have been updated with new base64-encoded payloads, consistently reflecting the serverFnMeta refactor across the renamed import pattern.

packages/start-plugin-core/tests/createServerFn/snapshots/client/createServerFnStarImport.tsx (1)

1-14: LGTM - Star import pattern snapshot properly updated.

All handlers have been consistently updated with new RPC payloads, correctly documenting the transformation for star import patterns (import * as TanStackStart).

e2e/react-start/server-functions/src/routes/middleware/index.tsx (1)

53-60: LGTM - Navigation link properly integrated.

The new link to the function-metadata route follows the established pattern and includes the appropriate data-testid for e2e testing. The label clearly describes the feature being tested.

packages/start-plugin-core/tests/createServerFn/snapshots/server-caller/createServerFnDestructuredRename.tsx (1)

1-14: LGTM - Server-caller snapshot correctly updated.

The transition from relative to absolute import paths (/test/src/test.ts?tss-serverfn-split) along with updated RPC payloads consistently documents the expected server-caller transformation output.

packages/start-plugin-core/tests/createServerFn/snapshots/server-caller/createServerFnDestructured.tsx (1)

1-24: LGTM - Comprehensive server-caller snapshot properly updated.

All seven handler variants have been consistently updated with absolute import paths and new RPC payloads, correctly documenting the expected transformation for the destructured import pattern.

packages/start-plugin-core/tests/createServerFn/snapshots/server-caller/createServerFnValidator.tsx (1)

1-6: LGTM - Validator snapshot correctly updated.

The snapshot properly documents the transformation for server functions with validators, using absolute import paths and updated RPC payloads consistent with the serverFnMeta refactor.

packages/start-server-core/src/createServerRpc.ts (1)

1-17: LGTM - Type-safe refactor to structured metadata.

The transition from a string functionId parameter to a structured ServerFnMeta object improves type safety and enables richer metadata propagation (id, name, filename). The implementation correctly derives the URL from serverFnMeta.id and attaches the full metadata object for downstream consumers. All call sites have been properly updated to pass the structured ServerFnMeta object—no unmigrated code remains.

packages/start-plugin-core/tests/createServerFn/snapshots/server-caller/createServerFnStarImport.tsx (1)

5-14: LGTM! Test snapshot updates align with metadata refactoring.

The updated base64-encoded payloads in the createSsrRpc calls now contain structured metadata (id, name, filename) instead of just a function identifier. These snapshot changes correctly reflect the compiler plugin's new output format for server function registration.

Based on learnings, these test snapshots document the transformation being validated and should be auto-generated by the test suite.

packages/start-client-core/src/createServerFn.ts (4)

7-11: LGTM! Proper type imports for metadata refactoring.

The imports correctly bring in the new ClientFnMeta and ServerFnMeta types that structure the server function metadata. This aligns with the new typed metadata approach documented in packages/start-client-core/src/constants.ts.


143-146: LGTM! Clear explanation of metadata propagation.

The comment and code correctly ensure that the full ServerFnMeta (containing id, name, and filename) from the provider file's extractedFn is used in server execution, rather than the partial ClientFnMeta (containing only id) from SSR/client callers. This distinction is important for middleware that may need access to the function name or filename.


337-337: LGTM! Type signature correctly requires full metadata.

The CompiledFetcherFn type now requires serverFnMeta: ServerFnMeta, which provides the complete metadata (id, name, filename) needed for server-side execution and middleware.


615-615: LGTM! Middleware options use client-side metadata appropriately.

The ServerFnMiddlewareOptions correctly uses ClientFnMeta (containing only the id) rather than the full ServerFnMeta. This is appropriate since middleware executing on the client side only needs the function identifier to route requests.

packages/start-plugin-core/tests/createServerFn/snapshots/client/createServerFnDestructured.tsx (1)

5-23: LGTM! Client snapshot updates are consistent with metadata refactoring.

All createClientRpc calls have been updated with new base64-encoded payloads that encode the structured metadata format. The changes are applied consistently across all server function exports (withUseServer, withArrowFunction, withArrowFunctionAndFunction, withoutUseServer, withVariable, withZodValidator, withValidatorFn).

Based on learnings, test snapshots document the expected transformation output.

packages/start-plugin-core/tests/createServerFn/snapshots/server-provider/factory.tsx (2)

27-31: LGTM! Server RPC registration uses new structured metadata API.

The createServerRpc call now accepts a structured object with { id, name, filename } instead of a positional string parameter. This aligns with the new ServerFnMeta type and provides richer metadata for server-side execution and middleware.

The metadata structure correctly includes:

  • id: Base64-encoded identifier
  • name: Original function variable name ("myAuthedFn")
  • filename: Source file path ("src/test.ts")

35-39: LGTM! Consistent metadata structure for admin function.

The deleteUserFn handler follows the same structured metadata pattern, maintaining consistency across the codebase.

packages/start-client-core/src/client/ServerFunctionSerializationAdapter.ts (2)

7-7: LGTM! Type guard correctly checks for new metadata structure.

The type guard now checks for serverFnMeta: { id: string } instead of the old functionId: string, correctly identifying objects that follow the new metadata format.


14-15: LGTM! Serialization adapter bridges old and new formats.

The serialization logic correctly:

  • Extracts the id from serverFnMeta for the wire format (toSerializable)
  • Reconstructs the client RPC using the extracted functionId (fromSerializable)

This maintains wire format compatibility while using the new structured metadata internally.

packages/start-plugin-core/tests/createServerFn/snapshots/client/factory.tsx (1)

27-28: LGTM! Factory snapshot updates align with metadata refactoring.

The createClientRpc calls for myAuthedFn and deleteUserFn have been updated with new base64-encoded payloads that reflect the structured metadata format. These changes are consistent with the broader refactoring.

Based on learnings, test snapshots document the expected compiler plugin transformation output.

packages/start-server-core/src/createSsrRpc.ts (3)

2-2: LGTM! Proper type import for SSR RPC metadata.

The import of ClientFnMeta is appropriate since SSR RPCs are created from encoded payloads that only contain the function id, not the full metadata with name and filename.


10-10: LGTM! SSR RPC correctly uses client-side metadata.

Creating a ClientFnMeta object with just the id is appropriate for SSR RPCs, which are instantiated from encoded identifiers without access to the full ServerFnMeta (name and filename) available on the provider side.


23-23: LGTM! API updated to expose structured metadata.

The returned object now exposes serverFnMeta instead of a bare functionId, making the API consistent with other RPC creation functions and providing a structured interface for accessing function metadata.

packages/start-client-core/src/client-rpc/createClientRpc.ts (3)

2-2: LGTM! Proper type import for client RPC metadata.

The import of ClientFnMeta is appropriate for client-side RPC creation, which only has access to the function identifier.


7-7: LGTM! Client RPC uses appropriate metadata structure.

Creating a ClientFnMeta object with the function id is correct for client-side RPC creation. The client side only needs the identifier to route requests to the server.


15-15: LGTM! Consistent API surface across RPC creation functions.

The returned object now exposes serverFnMeta instead of functionId, maintaining API consistency with createSsrRpc and other RPC creation functions. This provides a uniform interface for accessing function metadata across different RPC types.

e2e/react-start/server-functions/tests/server-functions.spec.ts (1)

668-749: LGTM! Comprehensive test for serverFnMeta middleware flow.

The test properly validates that:

  • Server middleware receives full serverFnMeta (id, name, filename)
  • Client middleware receives only the id
  • Metadata flows correctly through sendContext
  • Both SSR and client-side invocations work as expected
e2e/react-start/server-functions/src/routes/middleware/function-metadata.tsx (3)

5-20: LGTM! Middleware correctly captures and forwards serverFnMeta.

The implementation properly demonstrates the metadata flow:

  • Client middleware captures serverFnMeta and sends via sendContext
  • Server middleware receives both server-side serverFnMeta and client-captured metadata
  • Pattern aligns with the createMiddleware API

89-90: Type assertions acceptable for test demonstration.

The (as any) casts are intentionally used to access name and filename properties that should be undefined at runtime on the client side. The fallback to 'undefined' string ensures proper display in the test UI.

This pattern is appropriate for a test route that demonstrates runtime behavior, though in production code, proper type guards would be preferable.

Also applies to: 96-97, 147-149, 154-156


23-33: LGTM! Server function correctly returns captured metadata.

The handler properly returns both server-captured and client-captured metadata from the context, with clear comments explaining the client middleware limitations.

packages/start-plugin-core/tests/createServerFn/snapshots/server-provider/createServerFnDestructuredRename.tsx (1)

4-8: LGTM! Snapshot correctly reflects the serverFnMeta transformation.

The compiler transformation consistently updates all createServerRpc calls to use the structured object form with id, name, and filename fields, replacing the previous string-based ID approach. This aligns with the PR's goal of providing richer metadata for server functions.

Also applies to: 16-20, 28-32, 46-50

e2e/react-start/server-functions/src/routeTree.gen.ts (1)

1-10: Skipping review of autogenerated file.

This file is automatically generated by TanStack Router and should not be manually modified or reviewed.

Based on learnings, routeTree.gen.ts files are excluded from review.

packages/start-plugin-core/tests/createServerFn/snapshots/server-caller/factory.tsx (1)

27-28: LGTM! Snapshot correctly reflects absolute import path transformation.

The transformation from relative to absolute import paths (/test/src/test.ts?tss-serverfn-split) improves clarity and is consistently applied to both server function registrations. The RPC payload strings are updated accordingly.

packages/start-plugin-core/tests/createServerFn/snapshots/server-provider/createServerFnStarImport.tsx (1)

4-8: LGTM! Snapshot correctly handles star import transformation.

The compiler transformation correctly applies the serverFnMeta object structure even when using star import syntax (import * as TanStackStart). All handlers are consistently updated to use { id, name, filename } in their createServerRpc calls.

Also applies to: 18-22, 30-34, 48-52

packages/start-plugin-core/tests/createServerFn/snapshots/server-provider/createServerFnDestructured.tsx (1)

4-8: LGTM! Comprehensive snapshot demonstrates consistent transformation across handler patterns.

The compiler transformation correctly applies the serverFnMeta object structure ({ id, name, filename }) to all seven server function handlers, regardless of their implementation style (async function, arrow function, abstracted function, validators). This demonstrates robust handling of various syntax patterns.

Also applies to: 16-20, 24-28, 32-36, 44-48, 62-66, 74-78

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (4)
e2e/react-start/server-functions/tests/server-functions.spec.ts (2)

761-842: Reduce brittleness: avoid asserting exact filename string + normalize textContent.

textContent() can include whitespace/newlines, and the filename format may vary (posix vs windows separators, leading ./, etc.). Consider trimming + using a suffix/regex match for the filename assertion.

Proposed tweak
-  const loaderFilename = await page.getByTestId('loader-filename').textContent()
+  const loaderFilename = (await page.getByTestId('loader-filename').textContent())?.trim()

   // ...
-  expect(loaderFilename).toBe('src/routes/middleware/function-metadata.tsx')
+  expect(loaderFilename).toMatch(/routes\/middleware\/function-metadata\.tsx$/)

772-809: Avoid ! on textContent(); assert non-null explicitly for clearer failures.

Right now loaderFunctionId!.length will throw if textContent() is null, and the failure message won’t be very actionable.

Proposed tweak
-  expect(loaderFunctionId).toBeTruthy()
-  expect(loaderFunctionId!.length).toBeGreaterThan(0)
+  expect(loaderFunctionId).not.toBeNull()
+  expect(loaderFunctionId!.trim().length).toBeGreaterThan(0)
e2e/react-start/server-functions/src/routes/middleware/function-metadata.tsx (2)

5-20: Middleware context updates should be additive (don’t clobber other middleware).

If more middleware gets added later, next({ sendContext: { … } }) and next({ context: { … } }) can overwrite fields from earlier middleware.

Proposed tweak (additive merge)
 const metadataMiddleware = createMiddleware({ type: 'function' })
-  .client(async ({ next, serverFnMeta }) => {
+  .client(async ({ next, serverFnMeta, sendContext }) => {
     return next({
       sendContext: {
-        clientCapturedMeta: serverFnMeta,
+        ...sendContext,
+        clientCapturedMeta: serverFnMeta,
       },
     })
   })
   .server(async ({ next, serverFnMeta, context }) => {
     return next({
       context: {
+        ...context,
         serverCapturedMeta: serverFnMeta,
         clientCapturedMeta: context.clientCapturedMeta,
       },
     })
   })

89-98: Replace any casts with a tiny type guard (keep strict TS).

The as any reads are avoidable while still testing runtime absence of name/filename.

Proposed tweak
+function readOptionalStringField(obj: unknown, key: string): string | undefined {
+  if (!obj || typeof obj !== 'object') return undefined
+  const v = (obj as Record<string, unknown>)[key]
+  return typeof v === 'string' ? v : undefined
+}

 {/* Cast to any to test that name is not present at runtime */}
- {(loaderData.clientCapturedMeta as any)?.name ?? 'undefined'}
+ {readOptionalStringField(loaderData.clientCapturedMeta, 'name') ?? 'undefined'}

 {/* Cast to any to test that filename is not present at runtime */}
- {(loaderData.clientCapturedMeta as any)?.filename ?? 'undefined'}
+ {readOptionalStringField(loaderData.clientCapturedMeta, 'filename') ?? 'undefined'}

Also applies to: 147-157

📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between add0805 and 1510871.

📒 Files selected for processing (4)
  • e2e/react-start/server-functions/src/routeTree.gen.ts
  • e2e/react-start/server-functions/src/routes/middleware/function-metadata.tsx
  • e2e/react-start/server-functions/src/routes/middleware/index.tsx
  • e2e/react-start/server-functions/tests/server-functions.spec.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • e2e/react-start/server-functions/src/routes/middleware/index.tsx
🧰 Additional context used
📓 Path-based instructions (2)
**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

Use TypeScript strict mode with extensive type safety for all code

Files:

  • e2e/react-start/server-functions/src/routes/middleware/function-metadata.tsx
  • e2e/react-start/server-functions/src/routeTree.gen.ts
  • e2e/react-start/server-functions/tests/server-functions.spec.ts
**/*.{js,ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

Implement ESLint rules for router best practices using the ESLint plugin router

Files:

  • e2e/react-start/server-functions/src/routes/middleware/function-metadata.tsx
  • e2e/react-start/server-functions/src/routeTree.gen.ts
  • e2e/react-start/server-functions/tests/server-functions.spec.ts
🧠 Learnings (4)
📚 Learning: 2025-10-01T18:31:35.420Z
Learnt from: schiller-manuel
Repo: TanStack/router PR: 5330
File: e2e/react-start/custom-basepath/src/routeTree.gen.ts:58-61
Timestamp: 2025-10-01T18:31:35.420Z
Learning: Do not review files named `routeTree.gen.ts` in TanStack Router repositories, as these are autogenerated files that should not be manually modified.

Applied to files:

  • e2e/react-start/server-functions/src/routeTree.gen.ts
📚 Learning: 2025-12-17T02:17:55.086Z
Learnt from: schiller-manuel
Repo: TanStack/router PR: 6120
File: packages/router-generator/src/generator.ts:654-657
Timestamp: 2025-12-17T02:17:55.086Z
Learning: In `packages/router-generator/src/generator.ts`, pathless_layout routes must receive a `path` property when they have a `cleanedPath`, even though they are non-path routes. This is necessary because child routes inherit the path from their parent, and without this property, child routes would not have the correct full path at runtime.

Applied to files:

  • e2e/react-start/server-functions/src/routeTree.gen.ts
📚 Learning: 2025-10-08T08:11:47.088Z
Learnt from: nlynzaad
Repo: TanStack/router PR: 5402
File: packages/router-generator/tests/generator/no-formatted-route-tree/routeTree.nonnested.snapshot.ts:19-21
Timestamp: 2025-10-08T08:11:47.088Z
Learning: Test snapshot files in the router-generator tests directory (e.g., files matching the pattern `packages/router-generator/tests/generator/**/routeTree*.snapshot.ts` or `routeTree*.snapshot.js`) should not be modified or have issues flagged, as they are fixtures used to verify the generator's output and are intentionally preserved as-is.

Applied to files:

  • e2e/react-start/server-functions/src/routeTree.gen.ts
📚 Learning: 2025-09-28T21:41:45.233Z
Learnt from: nlynzaad
Repo: TanStack/router PR: 5284
File: e2e/react-start/basic/server.js:50-0
Timestamp: 2025-09-28T21:41:45.233Z
Learning: In Express v5, catch-all routes must use named wildcards. Use `/*splat` to match everything except root path, or `/{*splat}` (with braces) to match including root path. The old `*` syntax is not allowed and will cause "Missing parameter name" errors. This breaking change requires explicit naming of wildcard parameters.

Applied to files:

  • e2e/react-start/server-functions/src/routeTree.gen.ts
🧬 Code graph analysis (1)
e2e/react-start/server-functions/src/routes/middleware/function-metadata.tsx (2)
packages/start-client-core/src/createMiddleware.ts (1)
  • createMiddleware (29-62)
packages/start-client-core/src/createServerFn.ts (1)
  • createServerFn (54-188)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Preview
  • GitHub Check: Test
🔇 Additional comments (2)
e2e/react-start/server-functions/src/routeTree.gen.ts (1)

1-10: Autogenerated file: skip manual review; ensure it’s produced by the generator.

Given the header + repo convention, I’m not reviewing the contents beyond confirming it reflects the new route.

e2e/react-start/server-functions/src/routes/middleware/function-metadata.tsx (1)

35-38: LGTM for the e2e coverage intent (SSR + client call exercising serverFnMeta flow).

The route + UI testids are well-structured for validating the client vs server middleware serverFnMeta behavior.

Also applies to: 105-109

@schiller-manuel schiller-manuel merged commit 4fcfdaa into main Jan 11, 2026
6 checks passed
@schiller-manuel schiller-manuel deleted the serverfn-meta branch January 11, 2026 08:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants